#pragma once
#include "glMatrix.h"
#include "angleAxis.h"
#include "TVector.h"

class Quaternion
{
public:
	float w;
	TVector v;
	Quaternion(void);
	Quaternion(float _w, TVector _v);
	Quaternion(float _w,float _x,float _y,float _z);
	~Quaternion(void);
	float magnitude();
	void normalise();
	void conjugate();
	void inverse();
	bool isUnit();
	static Quaternion add(Quaternion q1,Quaternion q2);
	static Quaternion multiply(Quaternion q1, Quaternion q2);
	Quaternion scalarMultiply(float s);
	angleAxis toAngleAxis();
	glMatrix convertToMatrix();
	void constructFromMatrix(glMatrix M);
	Quaternion lerp(Quaternion q2,float timeStep);
	Quaternion slerp(Quaternion q2,float timeStep);
	void printQuat(char q[5]){
		printf("%s:%f %f %f %f\n",q,w,v._x,v._y,v._z);
	};
	

	friend Quaternion operator+(Quaternion q1,Quaternion q2)
	{
		return Quaternion::add(q1,q2);
	};

		friend Quaternion operator*(Quaternion q1,Quaternion q2)
	{
		return Quaternion::multiply(q1,q2);
	};

};